GTK_BUILDER_WARN_INVALID_CHILD_TYPE (notebook, type);
}
+static gboolean
+gtk_notebook_has_current_page (GtkNotebook *notebook)
+{
+ GtkNotebookPrivate *priv = notebook->priv;
+
+ return priv->cur_page &&
+ gtk_widget_get_visible (priv->cur_page->child);
+}
+
static gboolean
gtk_notebook_select_page (GtkNotebook *notebook,
gboolean move_focus)
if (!gtk_widget_is_focus (GTK_WIDGET (notebook)) || !priv->show_tabs)
return FALSE;
- if (!priv->cur_page ||
+ if (!gtk_notebook_has_current_page (notebook) ||
!priv->cur_page->reorderable)
return FALSE;
GtkNotebookPrivate *priv = notebook->priv;
GtkAllocation allocation, action_allocation;
GtkWidget *widget = GTK_WIDGET (notebook);
- GtkNotebookPage *visible_page = NULL;
- GList *tmp_list;
GtkPositionType tab_pos = get_effective_tab_pos (notebook);
gboolean is_rtl;
gint i;
- for (tmp_list = priv->children; tmp_list; tmp_list = tmp_list->next)
- {
- GtkNotebookPage *page = tmp_list->data;
- if (gtk_widget_get_visible (page->child))
- {
- visible_page = page;
- break;
- }
- }
-
- if (priv->show_tabs && visible_page)
+ if (priv->show_tabs && gtk_notebook_has_current_page (notebook))
{
if (rectangle)
{
case GTK_POS_TOP:
case GTK_POS_BOTTOM:
rectangle->width = allocation.width;
- rectangle->height = visible_page->requisition.height;
+ rectangle->height = priv->cur_page->requisition.height;
if (tab_pos == GTK_POS_BOTTOM)
rectangle->y += allocation.height - rectangle->height;
break;
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
- rectangle->width = visible_page->requisition.width;
+ rectangle->width = priv->cur_page->requisition.width;
rectangle->height = allocation.height;
if (tab_pos == GTK_POS_RIGHT)
rectangle->x += allocation.width - rectangle->width;
GtkNotebookPrivate *priv = notebook->priv;
gint stack_min, stack_nat, header_min, header_nat;
- if (!priv->show_tabs)
+ if (!priv->show_tabs || !gtk_notebook_has_current_page (notebook))
{
gtk_css_gadget_get_preferred_size (priv->stack_gadget,
orientation,
gtk_widget_size_allocate_with_baseline (page->child, (GtkAllocation *) allocation, baseline);
}
- if (priv->cur_page)
+ if (gtk_notebook_has_current_page (notebook))
gtk_widget_get_clip (priv->cur_page->child, out_clip);
}
stack_allocation = *allocation;
- if (!priv->show_tabs)
+ if (!priv->show_tabs || !gtk_notebook_has_current_page (notebook))
{
gtk_css_gadget_allocate (priv->stack_gadget, &stack_allocation, -1, out_clip);
}
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
- if (priv->cur_page)
+ if (gtk_notebook_has_current_page (notebook))
gtk_container_propagate_draw (GTK_CONTAINER (notebook),
priv->cur_page->child,
cr);
{
gtk_css_gadget_draw (priv->stack_gadget, cr);
- if (priv->show_tabs)
+ if (priv->show_tabs && gtk_notebook_has_current_page (notebook))
gtk_css_gadget_draw (priv->header_gadget, cr);
}
- if (priv->cur_page && priv->operation == DRAG_OPERATION_REORDER &&
+ if (gtk_notebook_has_current_page (notebook) && priv->operation == DRAG_OPERATION_REORDER &&
gtk_cairo_should_draw_window (cr, priv->drag_window))
{
gtk_notebook_draw_tab (notebook,
{
GtkNotebookPrivate *priv = notebook->priv;
- if (priv->show_tabs && priv->cur_page)
+ if (priv->show_tabs && gtk_notebook_has_current_page (notebook))
{
gtk_widget_grab_focus (GTK_WIDGET (notebook));
gtk_notebook_set_focus_child (GTK_CONTAINER (notebook), NULL);
gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (next));
}
- if (!priv->cur_page && gtk_widget_get_visible (child))
+ if (!gtk_notebook_has_current_page (notebook) && gtk_widget_get_visible (child))
{
gtk_notebook_switch_page (notebook, page);
/* focus_tab is set in the switch_page method */
child,
position);
- if (!priv->cur_page)
+ if (!gtk_notebook_has_current_page (notebook))
{
gtk_notebook_switch_page (notebook, page);
/* focus_tab is set in the switch_page method */
widget = GTK_WIDGET (notebook);
- if (!gtk_widget_get_mapped (widget) || !priv->cur_page)
+ if (!gtk_widget_get_mapped (widget) || !gtk_notebook_has_current_page (notebook))
return;
page = priv->cur_page;
widget = GTK_WIDGET (notebook);
- if (!gtk_widget_get_mapped (widget) || !priv->cur_page)
+ if (!gtk_widget_get_mapped (widget) || !gtk_notebook_has_current_page (notebook))
return;
page = priv->cur_page;
tab_pos = get_effective_tab_pos (notebook);
showarrow = FALSE;
- if (!priv->cur_page || !gtk_widget_get_visible (priv->cur_page->child))
+ if (!gtk_notebook_has_current_page (notebook))
return FALSE;
if (!priv->first_tab)
gint expanded_tabs;
gboolean tab_allocations_changed = FALSE;
- if (!priv->show_tabs || !priv->children || !priv->cur_page)
+ if (!priv->show_tabs || !gtk_notebook_has_current_page (notebook))
return;
min = max = tab_space = remaining_space = 0;